package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Grade;

/**
 * 
 * @author 
 *
 */
@DAO
public interface GradeDAO{
	
	@SQL("SELECT * FROM Grade WHERE 1=1 "
	    	    				    		        	+ " AND name=:t.name"
	        			    		        	+ " AND deleteFlag=:t.deleteFlag"
	        			    		        	+ " AND createAt=:t.createAt"
	        			    		        	+ " AND createUser=:t.createUser"
	        			    		        	+ " AND updateAt=:t.updateAt"
	        			    		        	+ " AND updateUser=:t.updateUser"
	        				+" ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Grade> query(@SQLParam("t") Grade grade);
    
    @SQL("select * from Grade where id=:1")
    Grade queryById(int id);
    
    @SQL("INSERT INTO Grade ("
    		        		+ "id,"
			        		+ "name,"
			        		+ "deleteFlag,"
			        		+ "createAt,"
			        		+ "createUser,"
			        		+ "updateAt,"
			        		+ "updateUser,"
							+") VALUES ("
							+ ":t.id,"
							+ ":t.name,"
							+ ":t.deleteFlag,"
							+ ":t.createAt,"
							+ ":t.createUser,"
							+ ":t.updateAt,"
							+ ":t.updateUser,"
					+")")
    void create(@SQLParam("t") Grade grade);
	
	@SQL("UPDATE Grade SET "
		    		    						    			        + "name=:t.name,"
		        					    			        + "deleteFlag=:t.deleteFlag,"
		        					    			        + "createAt=:t.createAt,"
		        					    			        + "createUser=:t.createUser,"
		        					    			        + "updateAt=:t.updateAt,"
		        					    			        + "updateUser=:t.updateUser,"
		        						+ " WHERE id=:t.id")
    void update(@SQLParam("t") Grade grade);
    
    @SQL("UPDATE Grade SET deleteFlag=0 WHERE id=:id")
    void deleteById(int id);
    
    @SQL("select id,name from Grade where deleteFlag=1")
    List<Map> asGradeEnum();
}